<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
   <%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
   <%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>首页</title>
<jsp:include page="/common/commonCss.jsp"/>
<jsp:include page="/common/commonJs.jsp"/>
<script type="text/javascript">
		//保存服务
		function  updateService(id){
			$("#status").val(id);
			if(!checkForm()){
				return;
			}
			$.messager.confirm('温馨提示', id=="1"?"你确定要保存吗?":"你确定要提交吗?", function(flag) {
				if (flag) {
					$("#hide_loading").show();
					$.ajax({
						url:"${basePath}filemanagement/customer/updateCustomerService.shtml",
						dataType:"json",
						type:"post",
						async:false,
						data:$("#saveService").serialize(),
						error : function(XMLHttpRequest) {
				 				ajaxError(XMLHttpRequest);
				 		},
						success:function(result){
							 if(result=="1"){
								 $("#hide_loading").hide();
								 window.location.href="${basePath}filemanagement/customer/serviceList.shtml";
							 }
						}
					});
				}
			});
		}
		function checkForm(){
			var  cusName=$("#cusName").val();
			if(checkIsNull(cusName)){
				alertWarning("姓名不能为空!");
				return false;
			}
			var  comments=$("#comments").val();
			if(checkIsNull(comments)){
				alertWarning("备注不能为空!");
				return false;
			}
			var  status=$("#status").val();
			if(status!="1"){
				var  mobile=$("#mobile").val();
				if(checkIsNull(mobile)){
					alertWarning("手机号码不能为空");
					return false;
				}
			}
			return true;
		}
		function checkIsTel(thisObj){
			 var value=$(thisObj).val();
			 var regexp=/^(0[0-9]{2,3}\-)?([2-9][0-9]{6,7})+(\-[0-9]{1,4})?$/;
			 if(!checkIsNull(value)){
				  if(!regexp.test(value)){
					   alertWarning("请输入正确的固话号码");
					   $(thisObj).val("");
				   }
			 }
		}
		function checkIsMobile(thisObj){
			 var value=$(thisObj).val();
			  var reg=/1[3,4,5,8][0-9]{9}$/;
			  if(!checkIsNull(value)){
				  if(!reg.test(value)){
					   alertWarning("请输入正确的手机号码!");
					   $(thisObj).val("");
				   }
			  }
		}
		 function checkIsNull(val){
			  if(val==""||$.trim(val)==""){
					return true;		  
			  }
			  return false;
		  }
		 
			//得到选中的id值.
			function getSelectVal(){
				var selectObj=$("input:[name='vipId']:checked");
				$("#fkMemId").val(selectObj.val());
				$("#cusName").val(selectObj.attr("cusName"));
				$("#selectVip").window('close');
			}
			//选择会员
			function selectVip(){
				initParams();
				$("#selectVip").window('open');
			}
			//初始化参数
			function initParams() {
				$("#pageNo").val("1");
				var myform = $("#vipInfo");
				var pagebean = new PageBean(myform);
				pagebean.setTableId("showData");
				pagebean.setFootId("foot");
				pagebean.setCallback(showData);
				setPagebeanObj(pagebean); //全局化pageBean对象
				pagebean.doPage();  //执行分页
			}
			//展示数据
			function showData(result){
				trimJsonArray(result);
				$(result).each(function(index,item){
		            var html="";
		            if(index==0){
			            html+="<tr><td><input type='radio' name='vipId'   cusName='"+item.name+"'  checked='checked'   value='"+item.pkMemId+"' />"+item.pkMemId+"</td>";
		            }else{
			            html+="<tr><td><input type='radio' name='vipId'  cusName='"+item.name+"'  value='"+item.pkMemId+"' />"+item.pkMemId+"</td>";
		            }
		            html+="<td>"+item.name+"</td>";
		            html+="<td>"+item.sex+"</td>";
		            html+="<td>"+item.age+"</td>";
		            html+="<td>"+item.countryDesc+"</td>";
		            if(item.isVip=="1"){
		            	html+="<td>是</td>";
		            }else{
		            	html+="<td>否</td>";
		            }
		            if(item.memType=="1"){
		                html+="<td>会员</td></tr>";
		            }else if(item.memType=="2"){
		                html+="<td>非会员</td></tr>";
		            }else{ 
		                html+="<td>访客</td></tr>";
		            }
					$("#showData").find("tr:eq("+index+")").after(html);
				});
			}
</script>
</head>
<body class="bg">
<div class="content m_auto">
	<div class="content_l mt10">
    	<ul>
    			<shiro:hasPermission name="filemanagement/listVip.shtml?type=1">
    						<li><a href="${basePath}filemanagement/listVip.shtml?type=1"><i class="nav_icon_b"></i><br>会员管理</a></li>
    			</shiro:hasPermission>
    			<shiro:hasPermission name="filemanagement/viewVistors.shtml?type=3">
            			<li><a href="${basePath}filemanagement/viewVistors.shtml?type=3"><i class="nav_icon_d"></i><br>访客管理</a></li>
    			</shiro:hasPermission>
    			<shiro:hasPermission name="filemanagement/listViewSingelTicket.shtml?type=2">
           				<li><a href="${basePath}filemanagement/listViewSingelTicket.shtml?type=2"><i class="nav_icon_a"></i><br>非会员管理</a></li>
    			</shiro:hasPermission>
    			<shiro:hasPermission name="parreserve/parReserveManages.shtml?indexflag=">
					<li><a href="${basePath }parreserve/parReserveManages.shtml?indexflag="><i class="nav_icon_g"></i><br>预约管理</a></li>
    			</shiro:hasPermission>
    			<shiro:hasPermission name="filemanagement/customer/serviceList.shtml">
						<li  class="content_hover"><a href="${basePath}filemanagement/customer/serviceList.shtml"><i class="nav_icon_h"></i><br>客户服务</a></li>
    			</shiro:hasPermission>
    			<shiro:hasPermission name="crm/jumpCrm.shtml">
						<li><a href="${basePath }crm/jumpCrm.shtml"><i class="nav_icon_n"></i><br>客户关系管理</a></li>
    			</shiro:hasPermission>
	</ul>
    </div>
    <div class="content_r mt10">
    	<form action="${basePath}filemanagement/customer/updateCustomerService.shtml" id="saveService" method="post">
    	  <input type="hidden" name="status"  id="status"   value=""/>
    	  <input type="hidden" name="careType"  id="careType"   value="${entity.careType}"/>
    	  <input type="hidden" name="pkCareformId"  id="pkCareformId"   value="${entity.pkCareformId}"/>
    	    <input type="hidden" name="fkMemId"  id="fkMemId"   value="${entity.fkMemId}"/>
    	   <dl class="order_add_l_dl w360_c pt30">
            <dd><label>服务请求类型：</label>投诉</dd>
            <dd><label>创建人：</label><input type="text" disabled value="${entity.userName}"   class="iput_t w200"></dd>
            <dd><label>创建时间 ：</label><input type="text" disabled value="${entity.createStartTime}"  class="iput_t w200"></dd>
            <dd>
                <label>途径：</label>
                <ul class="ul_radio fixed">
                  <c:choose>
                    		<c:when test="${entity.channel=='1'}">
                    		     <li><input type="radio" name="channel" value="1"  checked="checked">电话</li>
                   				 <li><input type="radio" name="channel" value="2">现场</li>
                   				 <li><input type="radio" name="channel" value="3">邮件</li>
                    		</c:when>
                    		<c:when test="${entity.channel=='2'}">
                    		 	 <li><input type="radio" name="channel" value="1" >电话</li>
                   				 <li><input type="radio" name="channel" value="2" checked="checked">现场</li>
                   				 <li><input type="radio" name="channel" value="3" >邮件</li>
                    		</c:when>
                    		<c:otherwise>
                    			 <li><input type="radio" name="channel" value="1" >电话</li>
                   				 <li><input type="radio" name="channel" value="2">现场</li>
                   				 <li><input type="radio" name="channel" value="3" checked="checked">邮件</li>
                    		</c:otherwise>
                    </c:choose>
                </ul>
            </dd>
            <dd><label>儿童姓名：</label><input type="text" value="${entity.cusName}" class="iput_t w100" name="cusName" id="cusName"><input type="button" class="btn ml10" value="选择" onclick="selectVip();"><font style="color:#F00">*</font></dd>
            <dd><label>固话：</label><input type="text"  name="tel" id="tel"  value="${entity.tel}" onblur="checkIsTel(this);"   class="iput_t w200"  title="固话号码格式，例如021-7930233,或加分机号021-7930181-0001"></dd>
            <dd><label>手机：</label><input type="text" value="${entity.mobile}" name="mobile" id="mobile"  onblur="checkIsMobile(this);"   class="iput_t w200"><span class="color_red ml5">*</span></dd>
            <dd><label>备注：</label><textarea class="textare w200 h80" name="comments" id="comments">${entity.comments}</textarea><span class="color_red ml5 vt">*</span></dd>
        </dl>
        </form>
        <div class="clear"></div>
        <br>
        <div class="btm_btn fixed">
            <dl>
                <dd><input type="button" class="btn" value="保存" onclick="updateService('1');" ></dd>
                <dd><input type="button" class="btn" value="提交" onclick="updateService('3');"></dd>
                <dd><input type="button" class="btn" value="返回" onclick="window.location.href='${basePath}filemanagement/customer/serviceList.shtml'"></dd>
            </dl>
        </div>
        
        <div id="hide_loading">
				<div class="loading"></div>    
			    <div class="loading_bg" ></div>	
		</div>
    </div>
</div>

<!---弹出层--->
<div id="selectVip" class="easyui-window" title="会员条件查询" data-options="modal:true,closed:true,iconCls:'icon-save'" style="width:800px; height:430px; position:relative;">
	<form action="${basePath}filemanagement/customer/getVipUserInfo.shtml" id="vipInfo">
    <input type="hidden" name="pageNo" id="pageNo" value="1">
    <input type="hidden" name="pageSize" value="8">
    <div class="w360_c">
    	<p class="m20">姓名/电话:<input type="text" class="iput_t w200"  name="nameOrTel"><input type="button" class="btn_l ml10" value="查询"  onclick="initParams();"></p>
    </div>
    <div class="m10">
    	<table class="table" id="showData">
           <tr>
                <th>编号</th>
                <th>姓名</th>
                <th>性别</th>
                <th>年龄</th>
                <th>国籍</th>
                <th>VIP</th>
                <th>类型</th>
            </tr>
      </table>
        <!---翻页-->
        <div class="page fr m10" id="foot">

        </div>
        <!----->
    </div>
    </form>
    <div class="btm_btn btm_bg">
    	<dl>
			<dd><input type="button" class="btn" onclick="getSelectVal();" value="确定"></dd>
			<dd><input type="button" class="btn" onclick="$('#selectVip').window('close')" value="返回"></dd>
        </dl>
    </div>
</div>
</body>
</html>
